
package com.ffcs.crmd.tsp.admin.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.JobDetailDeathDTO;
import com.ffcs.crmd.tsp.admin.api.facade.IJobDetailDeathFacade;
import com.ffcs.crmd.tsp.admin.entity.JobDetailDeath;
import com.ffcs.crmd.tsp.admin.service.IJobDetailDeathService;

@Service("jobDetailDeathFacade")
public class JobDetailDeathFacadeImpl extends AbstractCrmDomFacade implements IJobDetailDeathFacade {
    
    @Autowired
    private IJobDetailDeathService jobDetailDeathService;
    
    private PageInfo<JobDetailDeathDTO> copyPageInfo(PageInfo<JobDetailDeath> pageInfo) throws Exception {
        PageInfo<JobDetailDeathDTO> pageInfoDto = new PageInfo<JobDetailDeathDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), JobDetailDeathDTO.class));
        return pageInfoDto;
    }
    
    
    @Override
    public void delete(JobDetailDeathDTO jobDetailDeathDTO) throws Exception {
        JobDetailDeath jobDetailDeath = new JobDetailDeath();
        BeanUtils.applyIf(jobDetailDeath, jobDetailDeathDTO, false);
        jobDetailDeathService.delete(jobDetailDeath);
    }
    
    @Override
    public void delete(List<JobDetailDeathDTO> jobDetailDeathDTOList) throws Exception {
        List<JobDetailDeath> jobDetailDeathList = BeanUtils.copyList(jobDetailDeathDTOList, JobDetailDeath.class);
        jobDetailDeathService.delete(jobDetailDeathList);
    }
    
    @Override
    public List<JobDetailDeathDTO> query(JobDetailDeathDTO jobDetailDeathDTO) throws Exception {
        JobDetailDeath jobDetailDeath = new JobDetailDeath();
        BeanUtils.applyIf(jobDetailDeath, jobDetailDeathDTO, false);
        List<JobDetailDeath> jobDetailDeathList = jobDetailDeathService.query(jobDetailDeath);
        return BeanUtils.copyList(jobDetailDeathList, JobDetailDeathDTO.class);
    }

    @Override
    public PageInfo<JobDetailDeathDTO> queryPage(JobDetailDeathDTO jobDetailDeathDTO) throws Exception {
        JobDetailDeath jobDetailDeath = new JobDetailDeath();
        BeanUtils.applyIf(jobDetailDeath, jobDetailDeathDTO, false);
        PageInfo<JobDetailDeath> pageInfo = jobDetailDeathService.queryPage(jobDetailDeath, jobDetailDeathDTO.getPageNumber(), jobDetailDeathDTO.getPageSize());
        return copyPageInfo(pageInfo);
    }
    
    @Override
    public void reset(JobDetailDeathDTO jobDetailDeathDTO) throws Exception {
        JobDetailDeath jobDetailDeath = new JobDetailDeath();
        BeanUtils.applyIf(jobDetailDeath, jobDetailDeathDTO, false);
        jobDetailDeathService.reset(jobDetailDeath);
    }
    
    @Override
    public void reset(List<JobDetailDeathDTO> jobDetailDeathDTOList) throws Exception {
        List<JobDetailDeath> jobDetailDeathList = BeanUtils.copyList(jobDetailDeathDTOList, JobDetailDeath.class);
        jobDetailDeathService.reset(jobDetailDeathList);
    }

}
